extends Control

signal taskClosed

@onready var task=$task
@onready var completeUi=$completed
@onready var none=$none

var completed:=false
# 任务接受状态
var active:=false:
    set(v):
        active=v
        emit_signal('taskClosed')

var stick:=0


func _ready() -> void:
    task.visible=false
    completeUi.visible=false
    none.visible=false

func _physics_process(_delta: float) -> void:
    if active and stick==3:taskCompleted()


func newTask():
    if !completed:return showTask()
    none.visible=true
    await get_tree().create_timer(2).timeout
    none.visible=false

func showTask():task.visible=true

func taskCompleted():
    active=false
    completed=true
    completeUi.visible=true
    await get_tree().create_timer(3).timeout
    completeUi.visible=false


# ---------------信号------------------#
func _on_yes_pressed() -> void:
    task.visible=false
    active=true
    stick=0

func _on_no_pressed() -> void:
    task.visible=false
    active=false
    stick=0

